package cn.huangyunxing.api.service.impl.inner;

import cn.huangyunxing.api.common.ErrorCode;
import cn.huangyunxing.api.exception.BusinessException;
import cn.huangyunxing.api.mapper.UserMapper;
import cn.huangyunxing.api.service.UserService;
import cn.huangyunxing.common.model.entity.User;
import cn.huangyunxing.common.service.InnerUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * @author : HuangXing
 * @date : 2023/9/11 19:32
 */
@DubboService
public class InnerUserServiceImpl implements InnerUserService {
    @Resource
    private UserMapper userMapper;
    @Override
    public User getInvokeUser(String accessKey) {
        if (StringUtils.isAnyBlank(accessKey)){
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("access_key",accessKey);
        return userMapper.selectOne(queryWrapper);
    }
}
